package com.breakfast.fun.ui.user.info;

import android.widget.Button;
import android.widget.EditText;

import com.breakfast.fun.R;
import com.breakfast.fun.base.BaseActivity;
import com.breakfast.fun.util.T;
import com.breakfast.fun.view.widget.TitleBarView;

import butterknife.Bind;

public class UserModifyPwdActivity extends BaseActivity<UserModifyPwdPresenter, UserModifyPwdModel> implements UserModifyPwdContract.View {


    @Bind(R.id.tbv_modify_pwd)
    TitleBarView mTbvModifyPwd;
    @Bind(R.id.et_old_pwd)
    EditText mEtOldPwd;
    @Bind(R.id.et_new_pwd)
    EditText mEtNewPwd;
    @Bind(R.id.btn_modify_pwd)
    Button mBtnModifyPwd;

    @Override
    public int getLayoutId() {
        return R.layout.activity_user_modify_pwd;
    }

    @Override
    public void initView() {
        mTbvModifyPwd.setBack(this);
        mTbvModifyPwd.setTitleNoRight("修改密码");

        mBtnModifyPwd.setOnClickListener(v -> {
            if (mEtNewPwd.getText().length() < 6 || mEtOldPwd.getText().length() < 6) {
                T.show("密码长度不能小于6位");
                return;
            }
            presenter.modifyPwd(mEtOldPwd.getText().toString(), mEtNewPwd.getText().toString());
        });
    }

    @Override
    public void showSuccess() {
        T.show("修改成功");
        this.finish();
    }

}
